Mac安装OpenCV3 --with-contrib的错误处理

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

在Mac中安装OpenCV3时,如果需要安装--with-contrib,则会报错,OpenCV 3的安装命令为:

1
brew install opencv3 --with-contrib

错误信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
In file included from /usr/local/include/eigen3/Eigen/Core:422:
In file included from /usr/local/include/eigen3/Eigen/src/Core/ArrayBase.h:93:
/usr/local/include/eigen3/Eigen/src/Core/../plugins/ArrayCwiseUnaryOps.h:489:14: error: unknown type name 'LgammaReturnType'; did you mean 'DigammaReturnType'?
inline const LgammaReturnType
^
/usr/local/include/eigen3/Eigen/src/Core/../plugins/ArrayCwiseUnaryOps.h:471:74: note: 'DigammaReturnType' declared here
typedef CwiseUnaryOp<internal::scalar_digamma_op<Scalar>, const Derived> DigammaReturnType;
^
4 errors generated.
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make: *** [all] Error 2

这里主要是OpenCV 3 contrib支持eigen-3.2.10但不支持eigen-3.3.0,因此需要安装eigen-3.2.10,安装命令如下:

1
2
3
4
5
# 安装
brew install homebrew/versions/eigen32

# link
brew link --force eigen32

然后再安装OpenCV 3就可以了,当然如果不需要contrib选项,安装是没问题的。

如果有收获,可以请我喝杯咖啡!